﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InWare.InNutri.Applications.Util;
using InWare.InNutri.Model;

namespace InWare.InNutri.Applications.ViewModels
{
    public class PacienteListViewModel : ViewModelBase
    {
        #region Private fields
        private InNutriContext _context; 
        #endregion        
        
        #region Constructor

        public PacienteListViewModel()
        {
            _context = new InNutriContext();
        }

        #endregion

        public IEnumerable<Paciente> PacienteCollection
        {
            get
            {
                return _context.PacienteSet.OrderByDescending(p => p.IdPaciente).Take(50).ToList();
            }
        }

        private Paciente _selectedPaciente;

        public Paciente SelectedPaciente
        {
            get { return _selectedPaciente; }
            set 
            { 
                _selectedPaciente = value;
                base.OnPropertyChanged("SelectedPaciente");
            }
        }

        public void EditNewPaciente()
        {
            //Paciente paciente = new Paciente();
            //PacienteWindow pacienteWindows = new PacienteWindow();
            //pacienteWindows.DataContext = new PacienteViewModel(paciente);
            //pacienteWindows.ShowDialog();
        }

        public void EditSelectedPaciente()
        {
            //PacienteWindow pacienteWindows = new PacienteWindow();
            //pacienteWindows.DataContext = new PacienteViewModel(this.SelectedPaciente, _context);
            //pacienteWindows.ShowDialog();

        }
    }
}
